package com.liuzy.movie;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;

/**
 * @author liuzy
 * @since 2016年3月3日
 */
public class FILE {

	File file;
	FileWriter fw;
	BufferedWriter bw;

	public FILE(String filename) {
		try {
			file = new File(filename);
			if (!file.exists()) {
				file.createNewFile();
			}
			fw = new FileWriter(file, true);
			bw = new BufferedWriter(fw);
			bw.write("<html><head><meta charset='utf8' /></head><body><center><table>\n");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void append(String title, String download) {
		try {
			bw.write("<tr><td><a href='" + download + "' target='_blank'>" + title + "</a></td></tr>\n");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void close() {
		try {
			bw.write("\n</table></center></body></html>\n");
			fw.close();
			fw.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
